home *** CD-ROM | disk | FTP | other *** search
- #ifndef __DFILE__
- #define __DFILE__ 1
-
- #ifndef __DATAAREA__
- #include "DataArea.h"
- #endif
-
- #ifndef __STDFILE__
- #include "StdFile.h"
- #endif
-
-
-
- #pragma segment DFile
-
-
- /*µ class DFile
- ** This class binds a DataArea with a StdFile. The DataArea is written to
- ** using the normal DataArea methods. The Flush() method is called to copy
- ** the data from the DataArea to the output file. The purpose of this class
- ** is to enable cheap undo-able writes for the Formatting class
- */
- class DFile : public DataArea {
- public:
- DFile();
-
- short IDFile(const DFile *anArea);
- short IDFile(size_t initialSize = 0, size_t increment = 0);
- // Construct the DFile.
-
-
- void SetOutput(StdFile *anOutput);
- /*
- ** Set the StdFile to which output is written
- */
-
-
- void Putc(int aChar);
- void Puts(const char *aString);
- /*
- ** Routines to write to the data buffer
- */
-
-
- void Rewind();
-
-
- size_t Flush(size_t aThreshold = 0);
- /*
- ** Write the data in the DataArea to fOutput if the amount of data
- ** exceed aThreshold. Once written, the data cannot be re-written.
- */
-
- int Error() const;
- // Return the error that might have occurred during Flush()
-
- private:
- StdFile *fOutput;
- };
-
-
- //µ DFile::DFile
- #pragma segment DFile
- inline DFile::DFile()
- : DataArea(),
- fOutput(0)
- {
- }
-
-
- //µ DFile::IDFile
- #pragma segment DFile
- inline short DFile::IDFile(size_t initialSize, size_t increment)
- {
- return (IDataArea(initialSize, increment));
- }
-
-
- //µ DFile::Rewind
- #pragma segment DFile
- inline void DFile::Rewind()
- {
- SetCursor(0);
- }
-
-
- //µ DFile::Error
- #pragma segment DFile
- inline int DFile::Error() const
- {
- return (fOutput->Error());
- }
-
-
- #endif
-
-
-